/**
 * 发布消息
 */
function ifUpdate() {
	if (document.getElementById("all").disabled == true) {
		document.getElementById("selectuser").style.display = "none";
	}
}

function selectusers() {
	if (document.getElementById("all").checked == true) {
		// 选中所有人，将发送对象的选择范围隐藏
		document.getElementById("selectuser").style.display = "none";
	} else if (document.getElementById("some").checked == true) {
		// 选中特定对象，将发送对象的选择范围显示
		document.getElementById("selectuser").style.display = "block";
	}
}

function ckbumen() {
	if (document.getElementById("bumen").checked == true) {
		// 部门选中，部门下拉框可用
		document.getElementById("depart").disabled = false;
	} else {
		document.getElementById("depart").disabled = true;
	}
}
function ckygid() {
	// 员工选中，员工输入框可用
	if (document.getElementById("ygid").checked == true) {
		document.getElementById("usid").disabled = false;
	} else {
		document.getElementById("usid").disabled = true;
	}
}
function ckygname() {
	// 姓名选中，姓名输入框可用
	if (document.getElementById("ygname").checked == true) {
		document.getElementById("usname").disabled = false;
	} else {
		document.getElementById("usname").disabled = true;
	}
}

function showusers() {
	// 点击确定选择范围，发送对象div显示
	document.getElementById("showuser").style.display = "block";
}

var xmlHttp;
function createXMLHttRequest() {
	if (window.ActiveXObject)
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");// IE浏览器
	else if (window.XMLHttpRequest) // 非IE浏览器
		xmlHttp = new XMLHttpRequest();
	else
		alert("不能创建XMLHttpRequest");

}
function startRequest() {
	createXMLHttRequest();
	xmlHttp.onreadystatechange = fun;
	var usname = document.getElementById("usname").value;
	var url = "hzx/messageactionbyname?usname=" + usname;
	url=encodeURI(url);
	url=encodeURI(url);
	xmlHttp.open("post", url, true);	
	xmlHttp.send(null);
}
function fun() {
	if (xmlHttp.readyState == 4) {
		if (xmlHttp.status == 200) {
			var result = document.getElementById("divusername");
			result.style.display = "block";
			result.innerHTML = xmlHttp.responseText;

		}
	}
}
function qu(message) {
	document.getElementById("divusername").style.display = "none";
	document.getElementById("usname").value = message;
}

function mychange() {
	var quan = document.getElementById("allu");
	var ck = document.getElementsByName("touser");
	for (var i = 0; i < ck.length; i++) {
		ck[i].checked = quan.checked;
	}
}
function ch() {
	var quan = document.getElementById("allu");
	var ck = document.getElementsByName("touser");
	var flag = false;
	for (var i = 0; i < ck.length; i++) {
		if (ck[i].checked == false) {
			quan.checked = false;
			flag = true;
			break;
		}
		if (flag == false)
			quan.checked = true;
	}
}

function cktitle(){
	var mt = document.getElementById("mtitle").value;
	if (mt == "") {
		document.getElementById("ckmtitle").innerHTML = "用户名不能为空!";
		return false;
	}else{
		document.getElementById("ckmtitle").innerHTML = "";
		return true;
	}
}
function ckbtime(){
	var mb = document.getElementById("beginTime").value;
	if (mb == "") {
		document.getElementById("ckmbtime").innerHTML = "开始时间不能为空!";
		return false;
	}else{
		document.getElementById("ckmbtime").innerHTML = "";
		return true;
	}
}
function cketime(){
	var mb = document.getElementById("beginTime").value;
	var me = document.getElementById("endTime").value;
	
	if (me == "") {
		document.getElementById("ckmetime").innerHTML = "结束时间不能为空!";
		return false;
	}else if(me<mb){
		document.getElementById("ckmetime").innerHTML = "结束时间不能在开始时间之前!";
		me="";
		return false;
	}else{
		document.getElementById("ckmetime").innerHTML = "";
		return true;
	}
}
function ckcontent(){
	var mb = document.getElementById("mcontent").value;
	if (mb == "") {
		document.getElementById("ckmcontent").innerHTML = "内容不能为空!";
		return false;
	}else{
		document.getElementById("ckmcontent").innerHTML = "";
		return true;
	}
}
function ckall(){
	if (cktitle() && ckbtime() && cketime() && ckcontent()) {
		return true;
	} else {
		alert("请您填好添加的消息信息！");
		return false;
	}
}
